﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using System.Net;
using System.Net.Sockets;
using System.Collections;

namespace OINS
{
    public class ActiveHosts
    {
         public List<Host> activeHosts=new List<Host>();
         public int nrOfHosts=0;

         public void LoadHosts()
         {
             activeHosts.Clear();
             nrOfHosts = 0;
             FileInfo list = new FileInfo("active.txt");
             StreamReader stream = list.OpenText();
             String line;
             do
             {
                 line = stream.ReadLine();
                 if (line != null)
                 {
                     String[] temp = line.Split('\t');
                     activeHosts.Add(new Host(temp[0], temp[1]));
                     nrOfHosts++;
                 }
                 else
                     continue;
             } while (line != null);
             stream.Close();
         }
        public void Add(String name, String IP)
        {
            activeHosts.Add(new Host(name, IP));
            nrOfHosts++;



            


            StreamWriter stream = new StreamWriter("active.txt", true);

            stream.WriteLine(name + "\t" + IP);
            stream.Close(); 
        }

        
         

    }
}

